<style>
  .purchaseSignForForm-title {
    width: 100%;
  }

  .purchaseSignForForm-title .title {
    display: inline-block;
    font-size: 16px;
    font-weight: bold;
    color: #333333;
    line-height: 19px;
    position: relative;
    padding: 6px 0 19px 0;
  }

  .purchaseSignForForm-title .title:after {
    content: "";
    display: block;
    position: absolute;
    left: 0;
    bottom: 0;
    width: calc(100% + 6px);
    height: 3px;
    background: #0a8b0a;
  }
</style>
<!-- 正文开始 -->
<div class="layui-fluid">
  <div class="layui-card">
    <div class="layui-card-body">
      <!-- 头部操作栏 -->
      <div class="layui-form lay-header">
        <div class="toolbar">
          <div class="layui-form-item lay-query-content">
            <div class="lay-query-box">
              <div class="query-lt">

                <div class="layui-inline">
                  <label class="layui-form-label w-auto">签收编号：</label>
                  <div class="layui-input-inline mr0">
                    <input name="signNo" class="layui-input"  id="signNo" type="text" placeholder="请输入签收编号" />
                  </div>
                 </div>
                <div class="layui-inline">
                  <label class="layui-form-label w-auto">所属业务单：</label>
                  <div class="layui-input-inline mr0">
                    <input name="sn" class="layui-input" type="text" placeholder="请输入所属业务单" />
                  </div>
                </div>
                <div class="layui-inline">
                  <label class="layui-form-label w-auto">入库类型：</label>
                  <div class="layui-input-inline mr0">
                    <select id="inventoryTypeCodeSearch" name="inventoryTypeCode" lay-filter=""></select>
                  </div>
                </div>
                <div class="layui-inline">
                  <label class="layui-form-label w-auto">签收业务类型：</label>
                  <div class="layui-input-inline mr0">
                    <select id="signBusinessTypeSearch" name="signBusinessType" lay-filter=""></select>
                  </div>
                </div>
                <div class="layui-inline">
                  <label class="layui-form-label w-auto">计划接收时间：</label>
                  <div class="layui-input-inline">
                    <input id="pTime" class="layui-input date-icon" type="text"
                           placeholder="选择计划接收时间"
                           autocomplete="off" readonly/>
                    <input name="startTime" id="startTime" style="display: none"/>
                    <input name="endTime" id="endTime" style="display: none"/>
                  </div>
                </div>
                <div class="layui-inline">
                  <label class="layui-form-label w-auto">签收时间：</label>
                  <div class="layui-input-inline">
                    <input id="sTime" class="layui-input date-icon" type="text"
                           placeholder="选择签收时间"
                           autocomplete="off" readonly/>
                    <input name="startCreateTime" id="startCreateTime" style="display: none"/>
                    <input name="endCreateTime" id="endCreateTime" style="display: none"/>
                  </div>
                </div>
              </div>
              <div class="query-rt">
                <div class="layui-inline">
                  <button class="layui-btn icon-btn color-green" lay-filter="formSubSearchLog" lay-submit layui-form-keyDownSearch="true">查询</button>
                  <button class="layui-btn icon-btn color-white" lay-filter="resets" lay-submit>重置</button>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="lay-btn-rows">
          <div class="lay-btn-box">
            <div class="lay-btn-lt">
              <button id="purchaseSignForBtnAdd" class="layui-btn icon-btn color-reseda">添加入库签收</button>
              <button id="signForBtnExport" class="layui-btn icon-btn color-green">导出</button>
              <button id="purchaseSignForBtnConfirm" style="display: none" class="layui-btn icon-btn color-reseda">确认选择</button>
            </div>
            <div class="lay-btn-rt"></div>
          </div>
        </div>
      </div>
      <!-- 表格 -->
      <table class="layui-table" id="purchaseSignForTable" lay-filter="purchaseSignForTable"></table>
    </div>
  </div>
</div>

<!-- 表格操作列 -->
<script type="text/html" id="purchaseSignForTableBar">
  <a class="layui-btn layui-btn-xs layui-btn-primary" lay-event="view">详情</a>

  <!-- {{# if(d.status == '1'){ }} -->
  <!-- <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">修改</a> -->
  <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="confirm">确认</a>
  <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
  <!-- {{# } }} -->
  <!-- {{# if(d.status == '2'){ }} -->
  <!-- <a class="layui-btn layui-btn-xs layui-btn-primary" lay-event="view">详情</a> -->
  <!-- {{# } }} -->
  <button class="layui-btn  layui-btn-xs" lay-event="print">打印</button>
</script>

<!-- 表单弹窗 -->
<script type="text/html" id="purchaseSignForForm">
  <form lay-filter="purchaseSignForForm" class="layui-form open-form">
    <div class="open-model">
      <div class="open-auto">
        <input name="id" type="hidden" />
        <div class="layui-col-xs3">
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px;">入库类型</label>
            <div class="layui-input-block" style="margin-left: 130px;">
              <input id="inventoryTypeCode" name="inventoryTypeCode" type="hidden" />
              <select id="inventoryType" name="inventoryType" lay-filter="inventoryType"></select>
            </div>
          </div>
        </div>
        <div class="layui-col-xs3">
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px;">供应商/部门</label>
            <div class="layui-input-block" style="margin-left: 130px;">
              <select id="mainId" name="mainId" lay-filter="mainId"></select>
            </div>
          </div>
        </div>
        <div class="layui-col-xs3">
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px;">工单编号</label>
            <div class="layui-input-block" style="margin-left: 130px;">
              <select id="signTaskId" name="signTaskId" lay-filter="signTaskId"></select>
            </div>
          </div>
        </div>
        <div class="layui-col-xs3">
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px;">签收任务编号</label>
            <div class="layui-input-block" style="margin-left: 130px;">
              <input type="text" name="logisticsNo" disabled class="layui-input adv-disable" />
            </div>
          </div>
        </div>
        <div class="layui-col-xs3">
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px;">所属工单</label>
            <div class="layui-input-block" style="margin-left: 130px;">
              <input type="text" name="sn" disabled class="layui-input adv-disable" />
            </div>
          </div>
        </div>
        <div class="layui-col-xs3">
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px;">联系人</label>
            <div class="layui-input-block" style="margin-left: 130px;">
              <input type="text" name="businessContact" disabled class="layui-input adv-disable" />
            </div>
          </div>
        </div>
        <div class="layui-col-xs3">
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px;">采购部门</label>
            <div class="layui-input-block" style="margin-left: 130px;">
              <input type="text" name="departmentName" disabled class="layui-input adv-disable" />
            </div>
          </div>
        </div>
        <div class="layui-col-xs3">
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px;">创建人</label>
            <div class="layui-input-block" style="margin-left: 130px;">
              <input type="text" name="creatorName" disabled class="layui-input adv-disable" />
            </div>
          </div>
        </div>
        <div class="layui-col-xs3">
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px;">创建时间</label>
            <div class="layui-input-block" style="margin-left: 130px;">
              <input type="text" name="createTime" disabled class="layui-input adv-disable" />
            </div>
          </div>
        </div>
        <div id="logisticsContent"></div>
        <div class="layui-form-item">
          <div>
            <div class="layui-btn" id="addProduct" style="margin-top: 10px;">添加签收物料</div>
            <div id="productList">
              <table class="layui-table" id="purchaseDeliveryRecordProductTable" lay-filter="purchaseDeliveryRecordProductTable"></table>
            </div>
          </div>
        </div>
      </div>
      <div class="layui-form-item text-right">
        <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
        <button class="layui-btn" lay-filter="purchaseDeliveryRecordFormSubmit" lay-submit>提交</button>
      </div>
    </div>
  </form>
</script>
<script type="text/html" id="logisticsTempMain">
  <div class="layui-col-xs12">
    <div class="purchaseSignForForm-title">
      <h3 class="title">物流信息</h3>
    </div>
    <div class="line" style="margin-bottom: 15px;"></div>
  </div>
  <div class="layui-col-xs3">
    <div class="layui-form-item">
      <label class="layui-form-label" style="width: 100px;">物流记录编号</label>
      <div class="layui-input-block" style="margin-left: 130px;">
        <input type="text" name="logisticsNo" disabled class="layui-input adv-disable" />
      </div>
    </div>
  </div>
  <div class="layui-col-xs3">
    <div class="layui-form-item">
      <label class="layui-form-label" style="width: 100px;">运输方式</label>
      <div class="layui-input-block" style="margin-left: 130px;">
        <input type="text" name="transportModeDesc" disabled class="layui-input adv-disable" />
      </div>
    </div>
  </div>
  <div class="layui-col-xs3">
    <div class="layui-form-item">
      <label class="layui-form-label" style="width: 100px;">物流公司</label>
      <div class="layui-input-block" style="margin-left: 130px;">
        <input type="text" name="logisticsCompany" disabled class="layui-input adv-disable" />
      </div>
    </div>
  </div>
  <div class="layui-col-xs3" style="display: none" id="plateNoDiv">
    <div class="layui-form-item">
      <label class="layui-form-label" style="width: 100px;">车牌号</label>
      <div class="layui-input-block" style="margin-left: 130px;">
        <input type="text" name="plateNo" disabled class="layui-input adv-disable" />
      </div>
    </div>
  </div>
  <div class="layui-col-xs3" style="display: none" id="courierNoDiv">
    <div class="layui-form-item">
      <label class="layui-form-label" style="width: 100px;">快递单号</label>
      <div class="layui-input-block" style="margin-left: 130px;">
        <input type="text" name="courierNo" disabled class="layui-input adv-disable" />
      </div>
    </div>
  </div>
  <div class="layui-col-xs3">
    <div class="layui-form-item">
      <label class="layui-form-label" style="width: 100px;">联系电话</label>
      <div class="layui-input-block" style="margin-left: 130px;">
        <input type="text" name="phone" disabled class="layui-input adv-disable" />
      </div>
    </div>
  </div>
  <div class="layui-col-xs3">
    <div class="layui-form-item">
      <label class="layui-form-label" style="width: 100px;">物流录入类型</label>
      <div class="layui-input-block" style="margin-left: 130px;">
        <input type="text" name="enterTypeName" disabled class="layui-input adv-disable" />
      </div>
    </div>
  </div>
  <div class="layui-col-xs3">
    <div class="layui-form-item">
      <label class="layui-form-label" style="width: 100px;">录入人</label>
      <div class="layui-input-block" style="margin-left: 130px;">
        <input type="text" name="deliveryCreatorName" disabled class="layui-input adv-disable" />
      </div>
    </div>
  </div>
  <div class="layui-col-xs3">
    <div class="layui-form-item">
      <label class="layui-form-label" style="width: 100px;">物流录入时间</label>
      <div class="layui-input-block" style="margin-left: 130px;">
        <input type="text" name="deliveryCreateTime" disabled class="layui-input adv-disable" />
      </div>
    </div>
  </div>
</script>

<!--签收物料-->
<script type="text/html" id="workOrderMaterialList">
  <div class="layui-fluid">
    <div class="layui-card">
      <div class="layui-card-body">
        <!-- 头部操作栏 -->
        <div class="layui-form lay-header">
          <div class="toolbar">
            <div class="layui-form-item lay-query-content">
              <div class="lay-query-box">
                <div class="query-lt">
                  <div class="layui-inline">
                    <label class="layui-form-label w-auto">物料编号：</label>
                    <div class="layui-input-inline mr0">
                      <input name="skuCode" class="layui-input " type="text" placeholder="请输入物料编号" />
                    </div>
                  </div>
                  <div class="layui-inline">
                    <label class="layui-form-label w-auto">物料名称：</label>
                    <div class="layui-input-inline mr0">
                      <input name="productName" class="layui-input" type="text" placeholder="请输入物料名称" />
                    </div>
                  </div>
                  <div class="layui-inline">
                    <button class="layui-btn icon-btn color-green" lay-filter="workOrderMaterialSubSearchLog" lay-submit>查询</button>
                    <button class="layui-btn icon-btn color-white" lay-filter="workOrderMaterialResets" lay-submit>重置</button>


                    <button class="layui-btn layui-btn-normal icon-btn" id="confirmChoose">确认选择</button>
                  </div>
                </div>
                <div class="query-rt"></div>
              </div>
            </div>
          </div>
        </div>
        <!-- 表格 -->
        <table class="layui-table" id="workOrderMaterialListTable" lay-filter="workOrderMaterialListTable"></table>
      </div>
    </div>
  </div>
</script>

<!--签收物料html-->
<script type="text/html" id="signProductHtml">
  <!-- {{# layui.each(d, function(index, item){ }} -->
  <tr class="layui-form componentTr">
    <td><img src="{{item.productPic}}" style="height: 40px;" id="platformPic" /></td>
    <td id="skuCode">{{item.skuCode}}</td>
    <td>{{item.specifications}}</td>
    <td>{{item.productTypeName}}</td>
    <td>{{item.unitName}}</td>
    <td>{{item.purchaseQuantity}}</td>
    <td>{{item.quantity}}</td>
    <td>{{item.hasSignQuantity}}</td>
    <td>{{item.quantity - item.hasSignQuantity}}</td>
    <td id="productPackId">
      <select name="productPackId" lay-filter="getProductPack" style="width: 120px;"></select>
    </td>
    <td id="packUnit"></td>
    <td id="conversionRate"></td>
    <td id="signNum"></td>
    <td><a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a></td>
  </tr>
  <!-- {{# }) }} -->
</script>

<!--签收数量-->
<script type="text/html" id="signNum">
  <!-- {{# var signNum = ""; -->
  if(d.signNum != null){ signNum = d.signNum; } var mainUnitName = d.mainUnitName;
  <!-- }} -->
  <div class="layui-inline" style="display: flex; align-items: center;">
    <input
      name="signNum"
      placeholder="请输入签收数"
      type="text"
      style="text-align: center"
      value="{{signNum}}"
      lay-verify="required|quantity|compare"
      required
      class="layui-input"
      maxlength="10" />
    <span style="padding-left: 10px;">{{mainUnitName}}</span>
  </div>
</script>

<!-- 表格操作列 -->
<script type="text/html" id="purchaseDeliveryRecordProductTableBar">
  <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>

<!-- 详情弹窗 -->
<script type="text/html" id="purchaseSignForView">
  <form lay-filter="purchaseSignForView" class="layui-form open-form">
    <div class="open-model">
      <div class="open-auto">
        <input name="id" type="hidden" />
        <div class="layui-col-xs3">
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px;">入库类型</label>
            <div class="layui-input-block" style="margin-left: 130px;">
              <input type="text" name="inventoryTypeName" class="layui-input" />
            </div>
          </div>
        </div>
        <div class="layui-col-xs3">
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px;" id="supplierLabelName">供应商</label>
            <div class="layui-input-block" style="margin-left: 130px;">
              <input type="text" name="corporateName" class="layui-input" />
            </div>
          </div>
        </div>
        <div class="layui-col-xs3">
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px;">联系人</label>
            <div class="layui-input-block" style="margin-left: 130px;">
              <input type="text" name="businessContact" class="layui-input" />
            </div>
          </div>
        </div>
        <div class="layui-col-xs3">
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px;">采购部门</label>
            <div class="layui-input-block" style="margin-left: 130px;">
              <input type="text" name="departmentName" class="layui-input" />
            </div>
          </div>
        </div>
        <div class="layui-col-xs3">
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px;">签收业务类型</label>
            <div class="layui-input-block" style="margin-left: 130px;">
              <input type="text" name="signBusinessTypeName" class="layui-input" />
            </div>
          </div>
        </div>
        <div class="layui-col-xs3">
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px;" id="workOrderLabelName">工单编号</label>
            <div class="layui-input-block" style="margin-left: 130px;">
              <input type="text" name="waybillNo" class="layui-input" />
            </div>
          </div>
        </div>
        <div class="layui-col-xs3">
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px;">签收任务编号</label>
            <div class="layui-input-block" style="margin-left: 130px;">
              <input type="text" name="logisticsNo" class="layui-input" />
            </div>
          </div>
        </div>
        <div class="layui-col-xs3">
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px;" id="snLabelName">所属采购订单</label>
            <div class="layui-input-block" style="margin-left: 130px;">
              <input type="text" name="sn" class="layui-input" />
            </div>
          </div>
        </div>
        <div class="layui-col-xs3">
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px;">创建人</label>
            <div class="layui-input-block" style="margin-left: 130px;">
              <input type="text" name="creatorName" class="layui-input" />
            </div>
          </div>
        </div>
        <div class="layui-col-xs3">
          <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px;">创建时间</label>
            <div class="layui-input-block" style="margin-left: 130px;">
              <input type="text" name="createTime" class="layui-input" />
            </div>
          </div>
        </div>
        <div id="logisticsDiv" style="display: none">
          <div class="layui-col-xs12">
            <div class="purchaseSignForForm-title">
              <h3 class="title">物流信息</h3>
            </div>
            <div class="line" style="margin-bottom: 15px;"></div>
          </div>
          <div class="layui-col-xs3">
            <div class="layui-form-item">
              <label class="layui-form-label" style="width: 100px;">物流记录编号</label>
              <div class="layui-input-block" style="margin-left: 130px;">
                <input type="text" name="logisticsNo" class="layui-input" />
              </div>
            </div>
          </div>
          <div class="layui-col-xs3">
            <div class="layui-form-item">
              <label class="layui-form-label" style="width: 100px;">运输方式</label>
              <div class="layui-input-block" style="margin-left: 130px;">
                <input type="text" name="transportModeDesc" class="layui-input" />
              </div>
            </div>
          </div>
          <div class="layui-col-xs3">
            <div class="layui-form-item">
              <label class="layui-form-label" style="width: 100px;">物流公司</label>
              <div class="layui-input-block" style="margin-left: 130px;">
                <input type="text" name="logisticsCompany" class="layui-input" />
              </div>
            </div>
          </div>
          <div class="layui-col-xs3" style="display: none" id="plateNoDetailDiv">
            <div class="layui-form-item">
              <label class="layui-form-label" style="width: 100px;">车牌号</label>
              <div class="layui-input-block" style="margin-left: 130px;">
                <input type="text" name="plateNo" class="layui-input" />
              </div>
            </div>
          </div>
          <div class="layui-col-xs3" style="display: none" id="courierNoDetailiv">
            <div class="layui-form-item">
              <label class="layui-form-label" style="width: 100px;">快递单号</label>
              <div class="layui-input-block" style="margin-left: 130px;">
                <input type="text" name="courierNo" class="layui-input" />
              </div>
            </div>
          </div>
          <div class="layui-col-xs3">
            <div class="layui-form-item">
              <label class="layui-form-label" style="width: 100px;">联系电话</label>
              <div class="layui-input-block" style="margin-left: 130px;">
                <input type="text" name="phone" class="layui-input" />
              </div>
            </div>
          </div>
          <div class="layui-col-xs3">
            <div class="layui-form-item">
              <label class="layui-form-label" style="width: 100px;">物流录入类型</label>
              <div class="layui-input-block" style="margin-left: 130px;">
                <input type="text" name="enterTypeName" class="layui-input" />
              </div>
            </div>
          </div>
          <div class="layui-col-xs3">
            <div class="layui-form-item">
              <label class="layui-form-label" style="width: 100px;">录入人</label>
              <div class="layui-input-block" style="margin-left: 130px;">
                <input type="text" name="deliveryCreatorName" class="layui-input" />
              </div>
            </div>
          </div>
          <div class="layui-col-xs3">
            <div class="layui-form-item">
              <label class="layui-form-label" style="width: 100px;">物流录入时间</label>
              <div class="layui-input-block" style="margin-left: 130px;">
                <input type="text" name="deliveryCreateTime" class="layui-input" />
              </div>
            </div>
          </div>
        </div>
        <div class="layui-form-item">
          <div>
            <table class="layui-table" id="purchaseDeliveryRecordProductDetailTable" lay-filter="purchaseDeliveryRecordProductDetailTable"></table>
          </div>
        </div>
      </div>
      <div class="layui-form-item text-right">
        <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
      </div>
    </div>
  </form>
</script>

<!--入库签收单打印-->
<script type="text/html" id="printPurchaseSignForTemplate">
  <form lay-filter="printPurchaseSignForTemplateForm" class="layui-form open-form printTemplateForm">
    <div class="open-model">
      <div class="open-auto">
        <div class="my-print-box" id="printHtml">

        </div>
      </div>
      <div class="layui-form-item text-right">
        <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
        <button class="layui-btn" type="button" id="printPurchaseSignFor">打印</button>
      </div>
    </div>
  </form>
</script>
<script src="/admin/assets/libs/jquery/jquery-3.2.1.min.js"></script>
<script src="/admin/assets/libs/jquery/jQuery.print.js.js"></script>
<!-- js部分 -->
<script>
  layui.use(["layer", "form", "table", "admin", "laytpl", 'laydate'], async function () {
    var $ = layui.jquery;
    var layer = layui.layer;
    var form = layui.form;
    var laydate = layui.laydate;
    var table = layui.table;
    var config = layui.config;
    var admin = layui.admin;
    var upload = layui.upload;
    var laytpl = layui.laytpl;
    let nowData = {};
    if (typeof parentData != "undefined") {
      nowData = { ...parentData };
      if (nowData.eventName == "radio") {
        $("#purchaseSignForBtnConfirm").show();
        $("#purchaseSignForBtnAdd").hide();
      }
    }
    await admin.initDataSelectPro("enterprisecab/warehouse/admin/warehouseInventoryType/list", {
      status: 'enable',
      inventoryType: 'in',
      limit: '999'
    }, "inventoryTypeCodeSearch", "入库类型", null, "name", "code");
    await admin.initDataSelectPro("enterprise/dict/admin/dictLabel/select", {
      dictType: 'sign_business_type',
    }, "signBusinessTypeSearch", "签收业务类型", null, 'labelName', 'labelValue');
    laydate.render({
      elem: '#pTime',
      type: 'date',
      range: true,
      done: function (value, date, endDate) {

        if (value) {
          var dateValue = value.split(" - ");
          $("input[name='startTime']").val(dateValue[0] + " 00:00:00");
          $("input[name='endTime']").val(dateValue[1] + " 23:59:59");
        } else {
          $("input[name='startTime']").val("");
          $("input[name='endTime']").val("");
        }
      }
    });
    laydate.render({
      elem: '#sTime',
      type: 'date',
      range: true,
      done: function (value, date, endDate) {

        if (value) {
          var dateValue = value.split(" - ");
          $("input[name='startCreateTime']").val(dateValue[0] + " 00:00:00");
          $("input[name='endCreateTime']").val(dateValue[1] + " 23:59:59");
        } else {
          $("input[name='startCreateTime']").val("");
          $("input[name='endCreateTime']").val("");
        }
      }
    });

    // 渲染表格
    var insTb = table.render({
      elem: "#purchaseSignForTable",
      url: config.base + "enterprise/purchase/admin/purchaseSignFor/list",
      page: true,
      cellMinWidth: 100,
      where: { ...nowData?.where },
      cols: [
        [
          { type: "radio", width: 60, hide: !(nowData?.eventName == "radio") },
          { type: "numbers", width: 60, title: "序号" },
          { field: "signNo", align: "center", title: "签收编号", width: 150 },
          { field: "inventoryTypeName", align: "center", title: "入库类型", width: 120 },
          { field: "signBusinessTypeName", align: "center", title: "签收业务类型", width: 120 },
          { field: "sn", align: "center", title: "所属业务单号", width: 150 },
          { field: "supplierCode", align: "center", title: "主体编码", width: 180 },
          { field: "supplierName", align: "center", title: "主体名称", width: 200 },
          { field: "businessContact", align: "center", title: "联系人", width: 120 },
          { field: "signSkuNum", align: "center", title: "签收物料数" },
          { field: "totalAmount", align: "center", title: "金额" },
          { field: "waybillNo", align: "center", title: "物流单号", width: 160 },
          { field: "transportModeDesc", align: "center", title: "运输方式" },
          { field: "statusName", align: "center", title: "状态" },
          { field: "checkStatusName", align: "center", title: "质检状态" },
          { field: "createTime", align: "center", title: "签收时间", width: 160 },
          { align: "center", fixed: "right", toolbar: "#purchaseSignForTableBar", title: "操作", width: 240, hide: nowData?.eventName == "radio" }
        ]
      ]
    });

    // 工具条点击事件
    table.on("tool(purchaseSignForTable)", function (obj) {
      var data = obj.data;
      if (obj.event === "edit") {
        //修改
        openFormReady("edit", data);
        // showEditModel(data);
      } else if (obj.event === "view") {
        // 详情
        // showViewModel(data);
        openFormReady("detail", data);
      } else if (obj.event === "confirm") {
        // 确认
        doConfirm(data);
      } else if (obj.event === "del") {
        // 删除
        doDelete(obj);
      } else if (obj.event === 'print') {
        showPrintPurchaseSignForTemplate(data)
      }
    });

    //监听排序
    table.on("sort(purchaseSignForTable)", function (obj) {
      table.reload("purchaseSignForTable", {
        initSort: obj,
        where: {
          sort: obj.field,
          order: obj.type
        }
      });
    });

    // 添加按钮点击事件
    $("#purchaseSignForBtnAdd").click(function () {
      // showEditModel();
      openForm("add");
    });
    $("#purchaseSignForBtnConfirm").click(function () {
      let list = table.checkStatus("purchaseSignForTable").data;
      childData.list = list;
      layer.close(nowData.zindex);
      console.log(childData);
    });
    function openFormReady(eventName, data) {
      console.log("data", data);
      // if (data.inventoryTypeCode == 'CGR') {
      admin.req(
        "enterprise/purchase/admin/purchaseSignForProduct/list",
        {
          limit: 99999,
          purchaseSignForId: data.id
        },
        (res) => {
          if (res.code == 200) {
            data.purchaseSignForProducts = res.data;
            data.code = data.inventoryTypeCode;
            openForm(eventName, { ...data });
          }
        }
      );
      // } else if (data.inventoryTypeCode == 'SCR') {
      //     admin.req('production/productionPlan/admin/productionTheWorkOrder/list', {
      //         limit: 99999,
      //         // id: data.signTaskId
      //     }, (res) => {
      //         console.log(1, res.data.find(v => v.id == data.signTaskId))
      //         let list = [res.data.find(v => v.id == data.signTaskId)]
      //         list.forEach(v => {
      //             v.quantity = v.workQuantity
      //             v.hasSignQuantity = v.signedNum
      //         })
      //         data.purchaseSignForProducts = list
      //         data.code = data.inventoryTypeCode
      //         openForm(eventName, {...data})
      //         console.log('res', res)
      //     })
      // }
    }

    function openForm(eventName, data) {
      admin.formOpen({
        area: ["90%", "85%"],
        offset: "50px",
        title: "添加签收记录",
        path: "components/purchase/purchaseSignForForm.html",
        success: function () {
          parentData.eventName = eventName;
          parentData.data = data;
        }
      });
    }

    // 显示编辑弹窗
    function showEditModel(data) {
      admin.open({
        type: 1,
        area: ["80%", "85%"],
        offset: ["10%", "17%"],
        title: data ? "修改入库签收记录" : "添加入库签收记录",
        content: $("#purchaseSignForForm").html(),
        success: async function () {
          console.info(data, 8899);
          //入库类型
          var inventoryType;
          //入库类型列表
          await admin.initDataSelectPro(
            "enterprisecab/warehouse/admin/warehouseInventoryType/list",
            { inventoryType: "in", limit: 9999, status: "enable" },
            "inventoryType",
            "入库类型",
            async function (selectData, obj) {
              inventoryType = obj;
              console.log("生产类型", obj);
              $("#logisticsContent").html("");
              //出入库类型编码-赋值
              if (selectData.value) {
                $("#inventoryTypeCode").val(obj.code);
                if (obj.code == "PURCHASE_IN") {
                  laytpl(logisticsTempMain.innerHTML).render({}, function (html) {
                    $("#logisticsContent").html(html);
                  });
                  //供应商列表
                  // admin.initDataSelect('enterprise/purchase/admin/supplierInfoPass/list', {limit: 99999}, "mainId", null, "供应商", "corporateName", null);
                  await admin.initDataSelectPro(
                    "enterprise/purchase/admin/supplierInfoPass/list",
                    { limit: 99999 },
                    "mainId",
                    "供应商",
                    async (d) => {
                      if (inventoryType.code == "PURCHASE_IN") {
                        await admin.initDataSelectPro(
                          "enterprise/purchase/admin/purchaseDeliveryRecord/list",
                          {
                            limit: 99999,
                            filterWarehousingComplete: 1,
                            supplierId: d.value
                          },
                          "signTaskId",
                          "运单编号",
                          (d, obj) => {
                            if (d.value) {
                              obj.deliveryCreatorName = obj.creatorName;
                              obj.deliveryCreateTime = obj.createTime;

                              form.val("purchaseSignForForm", obj);

                              if (obj.transportMode == 0) {
                                $("#plateNoDiv").show();
                                $("#courierNoDiv").hide();
                              } else {
                                $("#plateNoDiv").hide();
                                $("#courierNoDiv").show();
                              }
                            }
                          },
                          "waybillNo"
                        );
                      }
                    },
                    "corporateName"
                  );
                  // 运单列表
                  // admin.initDataSelect('enterprise/purchase/admin/purchaseDeliveryRecord/list',{limit: 99999, filterWarehousingComplete: 1}, "signTaskId", null, "运单编号", "waybillNo", null);
                  await admin.initDataSelectPro(
                    "enterprise/purchase/admin/purchaseDeliveryRecord/list",
                    {
                      limit: 99999,
                      filterWarehousingComplete: 1
                    },
                    "signTaskId",
                    "运单编号",
                    (d, obj) => {
                      if (d.value) {
                        obj.deliveryCreatorName = obj.creatorName;
                        obj.deliveryCreateTime = obj.createTime;
                        if (obj.transportMode == 0) {
                          $("#plateNoDiv").show();
                          $("#courierNoDiv").hide();
                        } else {
                          $("#plateNoDiv").hide();
                          $("#courierNoDiv").show();
                        }
                      }
                    },
                    "waybillNo"
                  );
                } else if (obj.code == "PRODUCTION_IN") {
                }
              } else {
                $("#inventoryTypeCode").val("");
              }
            }
          );
          if (data) {
            // if (data.inventoryTypeCode == "PURCHASE_IN") {
            //     // 供应商列表
            //     admin.initDataSelect('enterprise/purchase/admin/supplierInfoPass/list', {limit: 99999}, "mainId", data.supplierId, "供应商", "corporateName", null);
            //     // 运单列表
            //     admin.initDataSelect('enterprise/purchase/admin/purchaseDeliveryRecord/list', {
            //         limit: 99999,
            //         filterWarehousingComplete: 1,
            //         supplierId: data.supplierId
            //     }, "signTaskId", data.signTaskId, "运单编号", "waybillNo", null);
            // }
          }

          // 供应商选择事件
          // form.on("select(mainId)", function (selectData) {
          //     if (inventoryType.code == "PURCHASE_IN") {
          //         $("#signTaskId").empty();
          //         // 运单列表
          //         admin.initDataSelect('enterprise/purchase/admin/purchaseDeliveryRecord/list', {
          //             limit: 99999,
          //             filterWarehousingComplete: 1,
          //             supplierId: selectData.value
          //         }, "signTaskId", null, "运单编号", "waybillNo", null);
          //     }
          // });

          // 运单选择事件
          // form.on("select(signTaskId)", function (selectData) {
          //     admin.req('enterprise/purchase/admin/purchaseDeliveryRecord/list', {
          //         limit: 99999,
          //         filterDeliveryComplete: 1
          //     }, function (res) {
          //         layer.closeAll('loading');
          //         if (res.code == 200) {
          //             res.data.forEach(purchaseDeliveryRecord => {
          //                 if (purchaseDeliveryRecord.id == selectData.value) {
          //                     //签收任务信息回显
          //                     purchaseDeliveryRecord.deliveryCreatorName = purchaseDeliveryRecord.creatorName;
          //                     purchaseDeliveryRecord.deliveryCreateTime = purchaseDeliveryRecord.createTime;
          //                     form.val("purchaseSignForForm", purchaseDeliveryRecord);
          //                     if (purchaseDeliveryRecord.transportMode == 0) {
          //                         $("#plateNoDiv").show();
          //                         $("#courierNoDiv").hide();
          //                     } else {
          //                         $("#plateNoDiv").hide();
          //                         $("#courierNoDiv").show();
          //                     }
          //                 }
          //             })
          //         } else {
          //             layer.msg(res.msg, {icon: 2});
          //         }
          //     }, 'GET');
          // });

          //签收数量验证
          form.verify({
            integer: [/^[0-9]\d*$/, "格式错误"],
            quantity: [/^[0-9]*(\.[0-9]{1,2})?$/, "格式错误"],
            compare: function (data, item) {
              console.info($(item));
              console.info($(item).parent());
              console.info($(item).parent().parent());
              console.info($(item).parent().parent().parent());
              console.info($(item).parent().parent().parent().prev().find("div").text());
              console.info($(item).parent().parent().parent().prev().prev().find("div").text());
              console.info($(item).parent().parent().parent().prev().prev().prev().find("div").text());
              console.info($(item).parent().parent().parent().prev().prev().prev().prev().find("div").text());
              var quantity = Number($(item).parent().parent().parent().prev().prev().prev().prev().find("div").text()); // 剩余签收数
              console.info("签收数量(按基础单位):" + data);
              console.info("待签收数:" + quantity);
              if (quantity < Number(data)) {
                return "签收数量(按基础单位)不能大于待签收数！";
              }
            }
          });

          var codeArr = [];
          var deliveryRecordProductList = [];

          // 添加签收物料
          $("#addProduct").click(function () {
            var signTaskId = $("form select[name='signTaskId']").val();
            if (signTaskId) {
              var workOrderMaterialList = admin.open({
                type: 1,
                area: ["80%", "85%"],
                offset: ["10%", "17%"],
                title: "物料列表",
                content: $("#workOrderMaterialList").html(),
                success: function () {
                  var codes = "";
                  for (var i = 0; i < codeArr.length; i++) {
                    if (i == 0) {
                      codes = '"' + codeArr[i] + '"';
                    } else {
                      codes += "," + '"' + codeArr[i] + '"';
                    }
                  }

                  // 渲染表格
                  var insTb = table.render({
                    elem: "#workOrderMaterialListTable",
                    url: config.base + "enterprise/purchase/admin/purchaseDeliveryRecordProduct/list",
                    where: {
                      purchaseDeliveryRecordId: signTaskId,
                      filterSignComplete: 1,
                      codes: codes
                    },
                    page: false,
                    cellMinWidth: 100,
                    cols: [
                      [
                        { type: "checkbox" },
                        { type: "numbers", align: "center", title: "序号", width: 70 },
                        { field: "skuCode", align: "center", title: "物料编号", width: 140 },
                        { field: "skuName", align: "center", title: "物料名称", width: 140 },
                        { field: "skuSpec", align: "center", title: "规格型号", width: 140 },
                        { field: "quantity", align: "center", title: "数量" },
                        { field: "mainUnitName", align: "center", title: "计量单位", width: 100 },
                        { field: "rate", align: "center", title: "税率(%)" },
                        { field: "taxPrice", align: "center", title: "含税单价" },
                        { field: "price", align: "center", title: "单价" },
                        { field: "amount", align: "center", title: "金额" },
                        { field: "tax", align: "center", title: "税额" },
                        { field: "totalAmount", align: "center", title: "合计金额" }
                      ]
                    ]
                  });

                  // 搜索
                  form.on("submit(workOrderMaterialSubSearchLog)", function (data) {
                    insTb.reload({ where: data.field, page: { curr: 1 } }, "data");
                  });

                  // 重置搜索
                  form.on("submit(workOrderMaterialResets)", function (data) {
                    $(".lay-header").find("select").val("");
                    $(".lay-header").find("input").val("");
                    let field = data.field;
                    for (let key in field) {
                      field[key] = "";
                    }
                    insTb.reload({ where: field, page: { curr: 1 } }, "data");
                  });

                  // 确认选择
                  $("#confirmChoose").click(function () {
                    var checkStatus = table.checkStatus("workOrderMaterialListTable"); //test即为基础参数id对应的值
                    var dataS = checkStatus.data;
                    for (var i = 0; i < dataS.length; i++) {
                      dataS[i].signProductId = dataS[i].id;
                    }
                    if (dataS.length == 0) {
                      layer.msg("请选择签收物料", { icon: 2, time: 1000 });
                    } else {
                      for (var i = 0; i < dataS.length; i++) {
                        deliveryRecordProductList.push(dataS[i]);
                        codeArr.push(dataS[i].skuCode);
                      }
                      layer.close(workOrderMaterialList);
                      // 获取数据集合并传入表格中
                      table.reload("purchaseDeliveryRecordProductTable", {
                        data: deliveryRecordProductList,
                        limit: deliveryRecordProductList.length
                      });
                    }
                  });
                }
              });
            } else {
              layer.msg("请选择工单编号", { icon: 2, time: 1000 });
            }
          });

          if (data) {
            //编辑时、禁止工单编号选择
            $("#inventoryType").attr("disabled", true);
            $("#mainId").attr("disabled", true);
            $("#signTaskId").attr("disabled", true);

            // 获取签收物料
            admin.req(
              "enterprise/purchase/admin/purchaseSignForProduct/list",
              {
                limit: 99999,
                purchaseSignForId: data.id
              },
              function (res) {
                if (200 == res.code) {
                  deliveryRecordProductList = res.data;
                  for (var i = 0; i < deliveryRecordProductList.length; i++) {
                    deliveryRecordProductList[i].purchaseSignForId = deliveryRecordProductList[i].id;
                    deliveryRecordProductList[i].baseUnitNum =
                      deliveryRecordProductList[i].signNum * deliveryRecordProductList[i].mainUnitRate + "" + deliveryRecordProductList[i].baseUnitName;
                    if (deliveryRecordProductList[i].subUnitRate != "" && deliveryRecordProductList[i].subUnitRate != undefined) {
                      deliveryRecordProductList[i].subUnitNum =
                        (deliveryRecordProductList[i].signNum * deliveryRecordProductList[i].mainUnitRate) / deliveryRecordProductList[i].subUnitRate +
                        "" +
                        deliveryRecordProductList[i].subUnitName;
                    }
                    codeArr.push(deliveryRecordProductList[i].skuCode);
                  }
                  table.reload("purchaseDeliveryRecordProductTable", {
                    data: deliveryRecordProductList,
                    limit: deliveryRecordProductList.length
                  });
                } else {
                  layer.msg("获取签收物料失败!", { icon: 2, time: 1000 });
                }
              },
              "GET"
            );
          }

          // 渲染表格
          var insTb = table.render({
            elem: "#purchaseDeliveryRecordProductTable",
            data: [deliveryRecordProductList],
            page: false,
            cellMinWidth: 100,
            cols: [
              [
                { type: "numbers", align: "center", height: 70, title: "序号" },
                { field: "purchaseSignForId", align: "center", title: "签收ID", hide: "true" },
                { field: "signProductId", title: "签收产品ID", hide: "true" },
                { field: "productTypeId", align: "center", title: "物料类型", hide: "true" },
                {
                  field: "productPic",
                  align: "center",
                  title: "物料图片",
                  hide: "true",
                  width: 140,
                  templet: function (d) {
                    return '<img src="' + d.productPic + '" id="platformPic"/>';
                  }
                },
                { field: "skuCode", align: "center", title: "物料编号", width: 140 },
                { field: "skuName", align: "center", title: "物料名称", width: 140 },
                { field: "skuSpec", align: "center", title: "规格号", width: 140 },
                { field: "baseUnitName", align: "center", title: "基础单位" },
                {
                  field: "purchaseQuantity",
                  align: "center",
                  title: "采购数量",
                  templet: function (d) {
                    return d.purchaseQuantity + "" + d.mainUnitName;
                  }
                },
                {
                  field: "quantity",
                  align: "center",
                  title: "发货数量",
                  templet: function (d) {
                    return d.quantity + "" + d.mainUnitName;
                  }
                },
                {
                  field: "hasSignQuantity",
                  align: "center",
                  title: "已签收数",
                  templet: function (d) {
                    return d.hasSignQuantity + "" + d.mainUnitName;
                  }
                },
                {
                  field: "surplusSignQuantity",
                  align: "center",
                  title: "待签收数",
                  templet: function (d) {
                    return d.quantity - d.hasSignQuantity + "" + d.mainUnitName;
                  }
                },
                {
                  field: "signNum",
                  align: "center",
                  title: "签收数(主计量)",
                  width: 170,
                  templet: "#signNum"
                },
                { field: "mainUnitRate", align: "center", title: "主计量单位换算率", hide: "true" },
                { field: "subUnitNum", align: "center", title: "辅计量单位数", width: 120 },
                { field: "subUnitName", align: "center", title: "辅计量单位名称", hide: "true" },
                { field: "subUnitRate", align: "center", title: "辅计量单位换算率", hide: "true" },
                { field: "baseUnitNum", align: "center", title: "基础单位数", width: 120 },
                {
                  align: "center",
                  toolbar: "#purchaseDeliveryRecordProductTableBar",
                  title: "操作",
                  width: 100,
                  fixed: "right"
                }
              ]
            ],
            done: function () {
              // 监听输入框-签收数量
              $("input[name='signNum']").on("input", function (e) {
                //获取input输入的值
                var curValue = e.delegateTarget.value;
                var curIndex = $(this).closest("tr").data("index");
                var baseUnitName, mainUnitRate, subUnitName, subUnitRate;
                $(this)
                  .closest("tr")
                  .find("td")
                  .each(function () {
                    if ($(this).data("field") == "baseUnitName") {
                      baseUnitName = $(this).find("div").text();
                    }
                    if ($(this).data("field") == "mainUnitRate") {
                      mainUnitRate = $(this).find("div").text();
                    }
                    if ($(this).data("field") == "subUnitName") {
                      subUnitName = $(this).find("div").text();
                    }
                    if ($(this).data("field") == "subUnitRate") {
                      subUnitRate = $(this).find("div").text();
                    }
                  });
                // 计算
                if (!$.isEmptyObject(deliveryRecordProductList[curIndex])) {
                  deliveryRecordProductList[curIndex].signNum = curValue;
                  //基础单位数量
                  if (mainUnitRate !== null && mainUnitRate !== "") {
                    var baseUnitNum = curValue * mainUnitRate;
                    deliveryRecordProductList[curIndex].baseUnitNum = baseUnitNum;
                    //数据回显
                    $(this)
                      .closest("tr")
                      .find("td")
                      .each(function () {
                        if ($(this).data("field") == "baseUnitNum") {
                          $(this)
                            .find("div")
                            .text(baseUnitNum + "" + baseUnitName);
                        }
                      });
                    //辅计量数据
                    if (subUnitRate !== null && subUnitRate !== "") {
                      var subUnitNum = baseUnitNum / subUnitRate;
                      var roundSubUnitNum = Number(subUnitNum.toFixed(4));
                      deliveryRecordProductList[curIndex].subUnitNum = roundSubUnitNum;
                      //数据回显
                      $(this)
                        .closest("tr")
                        .find("td")
                        .each(function () {
                          if ($(this).data("field") == "subUnitNum") {
                            $(this)
                              .find("div")
                              .text(roundSubUnitNum + "" + subUnitName);
                          }
                        });
                    }
                  }
                }
              });
            }
          });

          // 工具条点击事件
          table.on("tool(purchaseDeliveryRecordProductTable)", function (obj) {
            var data = obj.data;
            if (obj.event === "del") {
              // 删除
              doDelete(obj);
            }
          });

          // 删除签收物料
          function doDelete(obj) {
            var index = $(obj.tr).data("index");
            layer.confirm(
              "确定要删除吗？",
              {
                offset: "65px",
                skin: "layui-layer-admin"
              },
              function (i) {
                layer.close(i);
                var skuCode = obj.data.skuCode;
                if (codeArr.indexOf(skuCode) != -1) {
                  deliveryRecordProductList.splice(index, 1);
                  codeArr.splice(codeArr.indexOf(skuCode), 1);
                }
                table.reload("purchaseDeliveryRecordProductTable", {
                  data: deliveryRecordProductList,
                  limit: deliveryRecordProductList.length
                });
              }
            );
          }

          form.val("purchaseSignForForm", data);
          // 表单提交事件
          form.on("submit(purchaseDeliveryRecordFormSubmit)", function (d) {
            var purchaseSignForProducts = [];
            $("#productList")
              .find("tbody tr")
              .each(function (index, item) {
                var purchaseSignForProduct = {};
                if ($(item).find("td").length > 1) {
                  $(item)
                    .find("td")
                    .each(function (tdIndex, tdItem) {
                      if ($(tdItem).data("field") == "purchaseSignForId") {
                        purchaseSignForProduct.id = $(tdItem).find("div").text();
                      }
                      if ($(tdItem).data("field") == "signProductId") {
                        purchaseSignForProduct.signProductId = $(tdItem).find("div").text();
                      }
                      if ($(tdItem).data("field") == "signNum") {
                        purchaseSignForProduct.signNum = $(tdItem).find("input").val();
                      }
                    });
                  purchaseSignForProducts.push(purchaseSignForProduct);
                }
              });
            if (purchaseSignForProducts.length > 0) {
              layer.load(2);
              d.field.purchaseSignForProducts = purchaseSignForProducts;
              console.log(d.field);
              // admin.req(data ? 'enterprise/purchase/admin/purchaseSignFor/update' : 'enterprise/purchase/admin/purchaseSignFor/add', JSON.stringify(d.field), function (res) {
              //     layer.closeAll('loading');
              //     if (res.code == 200) {
              //         layer.msg(res.msg, {icon: 1});
              //         table.reload('purchaseSignForTable');
              //         layer.closeAll('page');
              //     } else {
              //         layer.msg(res.msg, {icon: 2});
              //     }
              // }, data ? 'PUT' : 'POST', false, "application/json");
            } else {
              layer.msg("至少添加一条签收物料！", { icon: 2 });
            }
            return false;
          });
        }
      });
    }

    // 打印入库签收单
    function showPrintPurchaseSignForTemplate(data) {
      admin.open({
        type: 1,
        area: ["1060px", "800px"],
        offset: '65px',
        title: '入库签收单',
        content: $('#printPurchaseSignForTemplate').html(),
        success: function () {
          let html = "";
          admin.req("enterprise/purchase/admin/purchaseSignForProduct/list", {limit: 10, purchaseSignForId: data.id}, function (res) {
            if (res.code === 200) {
              let detailList = res.data;
              let customerObj = {}, auditName = '';
              // admin.reqSync("enterprise/sell/admin/contactInfo/list", {selCustomerId: res.data.customerId}, function (obj) {
              //   if (obj.code == 200) {
              //     customerObj = obj.data.length > 0 ? obj.data[0] : {};
              //   }
              // });
              // // 获取审核人
              // admin.reqSync("user/admin/user/list", {limit: 9999}, function (obj) {
              //   if (obj.code == 200) {
              //     auditName = obj.data.find(v => v.id === res.data.auditId).name || '';
              //   }
              // });
              html += `<div class="print-title">入库签收单</div>
          <div class="flexCt print-tip-info">
            <div class="company">部门：${data.departmentName}</div>
            <div class="time">${data.createTime}</div>
          </div>
          <div class="print-table">
            <div class="print-view">
              <div class="print-nape ">
                <div class="cell">
                    <div class="name w-120 justify">签收任务编号</div>
                    <div class="val flex-1">${data.signNo}</div>
                </div>
                <div class="cell">
                    <div class="name w-120 justify">入库类型</div>
                    <div class="val flex-1">${data.inventoryTypeName}</div>
                </div>
              </div>
              <div class="print-nape ">
                <div class="cell">
                   <div class="name w-120 justify">主体名称</div>
                   <div class="val flex-1">${data.supplierName}</div>
                </div>
                <div class="cell">
                    <div class="name w-120 justify">联系人</div>
                    <div class="val flex-1">${data.businessContact}</div>
                </div>
              </div>
              <div class="print-nape ">
                <div class="cell">
                   <div class="name w-120 justify">签收业务类型</div>
                   <div class="val flex-1">${data.signBusinessTypeName}</div>
                </div>
                <div class="cell">
                    <div class="name w-120 justify">所属业务单号</div>
                    <div class="val flex-1">${data.sn}</div>
                </div>
              </div>
              <div class="print-nape ">
                <div class="cell">
                    <div class="name w-120 justify">签收物料数</div>
                    <div class="val flex-1">${data.signSkuNum}</div>
                </div>
                <div class="cell">
                   <div class="name w-120 justify">金额</div>
                   <div class="val flex-1">${data.totalAmount}</div>
                </div>
              </div>
              <div class="print-nape ">
                <div class="cell">
                   <div class="name w-120 justify">运输方式</div>
                   <div class="val flex-1">${data.transportModeDesc}</div>
                </div>
                <div class="cell">
                    <div class="name w-120 justify">物流单号</div>
                    <div class="val flex-1">${data.waybillNo}</div>
                </div>
              </div>
              <div class="print-nape ">
                <div class="cell">
                   <div class="name w-120 justify">签收时间</div>
                   <div class="val flex-1">${data.createTime}</div>
                </div>
                <div class="cell">
                    <div class="name w-120 justify">签收人</div>
                    <div class="val flex-1">${data.creatorName}</div>
                </div>
              </div>
              <div class="print-nape">
                <div class="cell w-100">
                  <div class="th v-60" style="padding: 0">序号</div>
                  <div class="th v-160">物料名称</div>
                  <div class="th v-160">物料编号</div>
                  <div class="th v-160">规格型号</div>
                  <div class="th">单位</div>
                  <div class="th" style="padding: 0;">采购数</div>
                  <div class="th" style="padding: 0;">发货数</div>
                  <div class="th" style="padding: 0;">已签收数</div>
                  <div class="th" style="padding: 0;">待签收数</div>
                </div>
              </div>`;
              let list = detailList.length > 10 ? detailList.slice(0, 10) : detailList;
              let fillValue = {}, allMoney = new Decimal(0);
              let filledArray = [...list, ...Array.from({ length: 10 - list.length }, () => fillValue)];
              filledArray.forEach((item, index) => {
                if (item.totalMoney) {
                  allMoney = allMoney.add(new Decimal(item.totalMoney))
                }
                html += `<div class="print-nape">
                    <div class="cell w-100">
                      <div class="td v-60" style="padding: 0">${index + 1}</div>
                      <div class="td v-160">${item.skuName || ''}</div>
                      <div class="td v-160">${item.skuCode || ''}</div>
                      <div class="td v-160">${item.skuSpec || ''}</div>
                      <div class="td">${item.mainUnitName || ''}</div>
                      <div class="td">${item.purchaseQuantity != undefined ? item.purchaseQuantity : ''}</div>
                      <div class="td">${item.quantity != undefined ? item.quantity : ''}</div>
                      <div class="td">${item.hasSignQuantity != undefined ? item.hasSignQuantity : ''}</div>
                      <div class="td">${item.quantity != undefined ? item.quantity - item.hasSignQuantity : ''}</div>
                    </div>
                  </div>`
              });
              html += `<div class="print-nape nape-btm">
                <div class="btm-sign lt">负责人签名与盖公司印章：</div>
                <div class="sign-rt flex-1">
                  <div class="cell w-100">
                    <div class="name flex-1">制单人</div>
                    <div class="name flex-1">确认人</div>
                  </div>
                  <div class="cell w-100">
                    <div class="val flex-1">${data.creatorName}</div>
                    <div class="val flex-1">${data.modifierName}</div>
                  </div>
                </div>
              </div>
            </div>
          </div>`
              $('#printHtml').html(html);

              $("#printPurchaseSignFor").click(function () {
                $('#printHtml').print({
                  debug: false,
                  importCSS: true,
                  printContainer: true,
                  operaSupport: false
                });
              })
            }
          });
        }
      })
    }

    // 显示详情弹窗
    function showViewModel(data) {
      let inventoryTypeCode = data.inventoryTypeCode;
      // if(inventoryTypeCode=='CGR'){
      //
      // }

      // console.info(data, 8989);
      // admin.open({
      //     type: 1,
      //     area: ['80%', '85%'],
      //     offset: ['10%', '17%'],
      //     title: '入库签收记录详情',
      //     content: $('#purchaseSignForView').html(),
      //     success: function () {
      //         //数据回显
      //         form.val('purchaseSignForView', data);
      //         if (data.inventoryTypeCode == "PURCHASE_IN") { //采购入库
      //             //采购入库 部分label信息赋值
      //             $("#supplierLabelName").text("供应商");
      //             $("#workOrderLabelName").text("运单编号");
      //             $("#snLabelName").text("所属采购订单");
      //             //显示物流信息
      //             $("#logisticsDiv").show();
      //             // 根据运输方式 显示车牌号、快递单号
      //             if (data.transportMode == 0) {
      //                 $("#plateNoDetailDiv").show();
      //                 $("#courierNoDetailDiv").hide();
      //             } else {
      //                 $("#plateNoDetailDiv").hide();
      //                 $("#courierNoDetailDiv").show();
      //             }
      //         }
      //
      //         // 渲染签收产品表格
      //         if (data.inventoryTypeCode == "PURCHASE_IN") { //采购入库
      //             table.render({
      //                 elem: '#purchaseDeliveryRecordProductDetailTable',
      //                 url: config.base + 'enterprise/purchase/admin/purchaseSignForProduct/list',
      //                 where: {purchaseSignForId: data.id},
      //                 page: false,
      //                 cellMinWidth: 100,
      //                 cols: [[
      //                     {type: 'numbers', width: 70, title: "序号"}
      //                     , {field: 'id', title: '采购签收任务ID', hide: 'true'}
      //                     , {field: 'productTypeId', title: '物料类型ID', hide: 'true'}
      //                     , {
      //                         field: 'productPic',
      //                         align: 'center',
      //                         title: '物料图片',
      //                         width: 120,
      //                         hide: 'true',
      //                         templet: function (d) {
      //                             return '<img src="' + d.productPic + '" style="height: 40px;" id="platformPic"/>'
      //                         }
      //                     }
      //                     , {field: 'skuCode', align: 'center', title: '物料编号', width: 140}
      //                     , {field: 'skuName', align: 'center', title: '物料名称', width: 140}
      //                     , {field: 'skuSpec', align: 'center', title: '规格号', width: 140}
      //                     , {field: 'baseUnitName', align: 'center', title: '基础单位'}
      //                     , {
      //                         field: 'purchaseQuantity', align: 'center', title: '采购数量',
      //                         templet: function (d) {
      //                             return d.purchaseQuantity + "" + d.mainUnitName;
      //                         }
      //                     }
      //                     , {
      //                         field: 'quantity', align: 'center', title: '发货数量',
      //                         templet: function (d) {
      //                             return d.quantity + "" + d.mainUnitName;
      //                         }
      //                     }
      //                     , {
      //                         field: 'signNum', align: 'center', title: '签收数量(主计量)', width: 170,
      //                         templet: function (d) {
      //                             return d.signNum + "" + d.mainUnitName;
      //                         }
      //                     }
      //                     , {
      //                         field: 'subUnitNum', align: 'center', title: '辅计量单位数', width: 120,
      //                         templet: function (d) {
      //                             if (d.subUnitRate != '' && d.subUnitRate != undefined) {
      //                                 return ((d.signNum * d.mainUnitRate) / d.subUnitRate) + "" + d.subUnitName;
      //                             } else {
      //                                 return '';
      //                             }
      //                         }
      //                     }
      //                     , {
      //                         field: 'baseUnitNum', align: 'center', title: '基础单位数',
      //                         templet: function (d) {
      //                             return (d.signNum * d.mainUnitRate) + "" + d.baseUnitName;
      //                         }
      //                     }
      //                 ]]
      //             });
      //         }
      //     }
      // });
    }

    // 确认
    function doConfirm(data) {
      layer.confirm(
        "确定要确认吗？",
        {
          offset: "200px",
          skin: "layui-layer-admin"
        },
        function (i) {
          layer.close(i);
          layer.load(2);
          admin.req(
            "enterprise/purchase/admin/purchaseSignFor/confirm",
            { id: data.id },
            function (res) {
              layer.closeAll("loading");
              if (res.code == 200) {
                layer.msg(res.msg, { icon: 1 });
                table.reload("purchaseSignForTable");
              } else {
                layer.msg(res.msg, { icon: 2 });
              }
            },
            "POST"
          );
        }
      );
    }

    // 删除
    function doDelete(obj) {
      layer.confirm(
        "确定要删除吗？",
        {
          offset: "200px",
          skin: "layui-layer-admin"
        },
        function (i) {
          layer.close(i);
          layer.load(2);
          admin.req(
            "enterprise/purchase/admin/purchaseSignFor/" + obj.data.id,
            {},
            function (res) {
              layer.closeAll("loading");
              if (res.code == 200) {
                layer.msg(res.msg, { icon: 1 });
                obj.del();
              } else {
                layer.msg(res.msg, { icon: 2 });
              }
            },
            "DELETE"
          );
        }
      );
    }

    // 搜索
    form.on("submit(formSubSearchLog)", function (data) {
      insTb.reload({ where: data.field, page: { curr: 1 } }, "data");
    });

    // 重置搜索
    form.on("submit(resets)", function (data) {
      $(".lay-header").find("select").val("");
      $(".lay-header").find("input").val("");
      let field = data.field;
      for (let key in field) {
        field[key] = "";
      }
      insTb.reload({ where: field, page: { curr: 1 } }, "data");
    });

    $('#signForBtnExport').click(function () {
      let signNo = $('#signNo').val();
      let startTime = $('#startTime').val();
      let endTime = $('#endTime').val();

      // 创建一个对象来保存所有可能的查询参数
      let queryParams = {
        signNo: signNo,
        startTime: startTime,
        endTime: endTime
      };

      // 过滤掉值为 undefined 的属性
      queryParams = Object.keys(queryParams)
              .filter(key => queryParams[key] !== undefined && queryParams[key] !== '')
              .reduce((obj, key) => {
                obj[key] = queryParams[key];
                return obj;
              }, {});

      // 将过滤后的参数对象转换为查询字符串
      let queryString = new URLSearchParams(queryParams).toString();

      // 获取当前日期和时间
      let now = new Date();
      let year = now.getFullYear();
      let month = String(now.getMonth() + 1).padStart(2, '0'); // 注意：getMonth() 返回值是 0-11
      let day = String(now.getDate()).padStart(2, '0');
      let hour = String(now.getHours()).padStart(2, '0');
      let minute = String(now.getMinutes()).padStart(2, '0');
      let second = String(now.getSeconds()).padStart(2, '0');

      // 格式化日期和时间为 YYYYMMDD_HHMMSS 形式
      let formattedDateTime = `${year}${month}${day}_${hour}${minute}${second}`;

      // 设置下载文件名为 "产品数据_YYYYMMDD_HHMMSS.xls"
      let fileName = `入库签收记录_${formattedDateTime}.xls`;

      // 创建完整的URL，包括查询参数和文件名作为额外参数（如果后端支持的话）
      let fullUrl = config.base + 'enterprise/purchase/admin/purchaseSignFor/export?' + queryString + '&fileName=' + encodeURIComponent(fileName);

      // 使用 window.open 打开新页面进行下载
      window.open(fullUrl + '&Authorization=Bearer ' + encodeURIComponent(config.getToken()), '_blank');
      // 注意：这里假设后端能够处理 fileName 参数，并根据它设置响应头中的 Content-Disposition 来指定下载文件名。
      // 如果后端不支持通过 URL 参数指定文件名，你可能需要调整后端代码来接受这种请求方式。
    });





  });



</script>
